package com.fmsz.xmly.activitys.myselfactivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.fmsz.xmly.R;
import com.fmsz.xmly.activitys.myselfactivity.subsettingactivity.AlarmActivity;
import com.fmsz.xmly.activitys.myselfactivity.subsettingactivity.CacheActivity;
import com.fmsz.xmly.activitys.myselfactivity.subsettingactivity.CachePlaceActivity;
import com.fmsz.xmly.activitys.myselfactivity.subsettingactivity.HelpActivity;
import com.fmsz.xmly.activitys.myselfactivity.subsettingactivity.PushActivity;
import com.fmsz.xmly.utils.SwitchButtonView;

/**
 * 设置界面
 */

public class SettingActivity extends AppCompatActivity implements View.OnClickListener {
    private RelativeLayout alarm;
    private RelativeLayout close;
    private RelativeLayout cachesetting;
    private RelativeLayout downloadplace;
    private RelativeLayout push;
    private RelativeLayout update;
    private RelativeLayout help;
    private RelativeLayout about;
    private ImageView btn_back_setting;
    private TextView downplace;
    private SwitchButtonView switchButtonView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        alarm = (RelativeLayout) findViewById(R.id.alarm);
        alarm.setOnClickListener(this);

        close = (RelativeLayout) findViewById(R.id.close);
        close.setOnClickListener(this);

        cachesetting = (RelativeLayout) findViewById(R.id.cacheplace);
        cachesetting.setOnClickListener(this);

        downloadplace = (RelativeLayout) findViewById(R.id.downloadplace);
        downloadplace.setOnClickListener(this);

        push = (RelativeLayout) findViewById(R.id.push);
        push.setOnClickListener(this);

        update = (RelativeLayout) findViewById(R.id.update);
        update.setOnClickListener(this);

        help = (RelativeLayout) findViewById(R.id.help);
        help.setOnClickListener(this);

        about = (RelativeLayout) findViewById(R.id.about);
        about.setOnClickListener(this);

        btn_back_setting = (ImageView) findViewById(R.id.btn_back_setting);
        btn_back_setting.setOnClickListener(this);


        downplace= (TextView) findViewById(R.id.downplace);

        switchButtonView= (SwitchButtonView) findViewById(R.id.SwitchButtonView_setting);
        switchButtonView.setOnSwitchListener(new SwitchButtonView.onSwitchListener() {
            @Override
            public void onSwitchChanged(boolean isCheck) {

            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.alarm://特色闹铃
                Intent alarm = new Intent(this, AlarmActivity.class);
                startActivity(alarm);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_left);
                break;
            case R.id.close://定时关闭
                Toast.makeText(this, "popwindow", Toast.LENGTH_SHORT).show();
                break;
            case R.id.btn_back_setting://返回箭头
                finish();
                break;
            case R.id.cacheplace://缓存
                Intent cachesetting = new Intent(this, CacheActivity.class);
                startActivity(cachesetting);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_left);
                break;
            case R.id.downloadplace://下载位置
                Intent downloadplace = new Intent(this, CachePlaceActivity.class);
                startActivity(downloadplace);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_left);
                break;
            case R.id.push://推送
                Intent push = new Intent(this, PushActivity.class);
                startActivity(push);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_left);
                break;
            case R.id.update://更新
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("温馨提示");
                builder.setMessage("付费节目支持优惠券啦,各种花式优惠等你来体验哦~");
                builder.setPositiveButton("升级版本", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                builder.setNegativeButton("下次再说", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                builder.setNeutralButton("忽略", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {


                    }
                });
                builder.setCancelable(true);
                builder.show();
                break;
            case R.id.help:
                Intent help = new Intent(this, HelpActivity.class);
                startActivity(help);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_left);
                break;
            case R.id.about:
                Toast.makeText(this, "关于!!!!", Toast.LENGTH_SHORT).show();
                break;

        }

    }

}
